<template>
	<view class="wrap">
		<u-card class="task-list-item" :show-head="false" :border="true" padding="36" margin="18rpx"
			:head-border-bottom="false">
			<view slot="body">
				<u-row gutter="26" style="gap:24rpx">
					<u-col span="12">
						<view class="apply-text"><span>保养单号：</span>{{this.maintain_order_number}}</view>
					</u-col>
					<u-col span="12">
						<view class="apply-text"><span>保养时间：</span>{{this.maintain_date}}</view>
					</u-col>
					<u-col span="12">
						<view class="apply-text"><span>保养人：</span>{{this.nice_name}}</view>
					</u-col>
				</u-row>
			</view>
		</u-card>

		<view class="">
			<view class="head-text">保养工单</view>
			<u-card class="task-list-item" :show-head="false" :border="true" padding="36" margin="24rpx"
				:head-border-bottom="false">
				<view slot="body">
					<u-row gutter="26" style="gap:24rpx">
						<u-col span="12">
						<!-- 	<view class="checkbox-group">
								<u-checkbox shape="square" v-model="allUnchecked"
									@change="handleAllChange">全不选</u-checkbox>
								<u-checkbox shape="square" v-model="allChecked"
									@change="handleAllChange">全选</u-checkbox>

							</view> -->
							<view v-for="(item,index) in equipment_infos" :key="item.id" style="margin-bottom: 48rpx;">
								<view class="container-checked">
									<view>{{item.process_name}}-{{item.equipment_name}}</view>
									<u-checkbox-group @change="checkboxGroupChange" >
										<u-checkbox  @change="checkboxChange"  v-model="checkItem.checked" label-size="16"
											v-for="(checkItem,checkIndex) in item.checkedList" :key="checkIndex"
											shape="circle" :name="checkItem.name">{{checkItem.name}}</u-checkbox>
									</u-checkbox-group>
								</view>
								<view class="container-tips">
									<view>备注</view>
									<u-input v-model="item.remark" :type="type" :border="border" :disabled="true"/>
								</view>
							</view>

						</u-col>
					</u-row>
				</view>
			</u-card>
		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				id: "",
				maintain_order_number: "",
				maintain_date: "",
				nice_name: "",
				equipment_infos: [{
					equipment_id: "169267377219940",
					equipment_name: "2号污水提升泵",
					is_maintain: 1,
					process_name: "进水",
					remark: "1"
				}],
				allChecked: false, // 全选的checkbox状态
				allUnchecked: true, // 全不选的checkbox状态
				// checkedList: [ // checkbox列表
				// 	{
				// 		name: '已保养',
				// 		checked: false
				// 	},
				// 	{
				// 		name: '未保养',
				// 		checked: false
				// 	},
				// ],
				type: 'text',
				border: true,
			}
		},
		onLoad(options) {
			this.id = options.id
			this.orderView(this.id)
		},
		onReady() {

		},
		methods: {
			checkboxChange(e) {
				console.log(e, "checkboxChange");
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				console.log(e, "checkbox-group");
			},
			handleAllChange(e) {
				console.log(e);
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			orderView(id) {
				console.log(id)
				this.$u.api.orderView({
					"algorithmProcessId": "water_maintain_order_view",
					"param": {
						"data": {
							id: id,
						}
					}
				}).then(res => {
					this.nice_name = res.data.data.result.nice_name
					this.maintain_order_number = res.data.data.result.maintain_order_number
					this.maintain_date = res.data.data.result.maintain_date
					this.equipment_infos = JSON.parse(res.data.data.result.equipment_infos)
					this.equipment_infos.forEach(item => {
						item.checkedList = [{
								name: '已保养',
								checked: item.is_maintain === 1, // 根据is_maintain的值设置checked属性
								disabled:false
							},
							{
								name: '未保养',
								checked: item.is_maintain === 0, // 根据is_maintain的值设置checked属性
								disabled:false
							}
						];
					});

					console.log(this.equipment_infos, '11111111')
				}).catch(error => {
					this.$u.toast('查询异常');
					console.error(error);
				});
			},
		},
	};
</script>
<style lang="scss" scoped>
	@import '../../../common/uni.css';
	@import 'style/upkeepView.css';
</style>